package com.centling.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.centling.entity.Product;
import com.centling.service.IProductService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

@Controller
@RequestMapping("/product")
public class ProdctController {

	@Autowired
	public IProductService productService;
	
	@RequestMapping("/getJsonData")
	@ResponseBody
	public Object getJsonData(){
		List<Product> productList = productService.getProductList();
		/*ObjectMapper mapper = new ObjectMapper();
		String json= null;
		try {
			json = mapper.writeValueAsString(productList);
		} catch (JsonProcessingException e) {
			e.printStackTrace();
		}*/
		return productList;
	}
}
